<template>
    <div class="main">
        <div class="header">
            <el-menu class="el-menu-demo header-menu" mode="horizontal" :ellipsis="false" default-active="1"
                @select="handleSelect">
                <el-menu-item index="0">首页</el-menu-item>
                <el-menu-item index="1">用户管理</el-menu-item>
                <el-menu-item index="2">其他</el-menu-item>
                <div class="flex-grow"></div>
                <el-sub-menu index="10" class="menu-logout">
                    <template #title>欢迎您，root</template>
                    <el-menu-item index="11" @click="logout">登出</el-menu-item>
                </el-sub-menu>
            </el-menu>
        </div>
        <div class="content">
            <div class="user-main" v-show="currentActive === 1">
                <el-card class="user-box-card">
                    <div class="user-content">
                        <div class="user-content-table">
                            <el-table :data="userList"></el-table>
                            <el-table-column label="ID" prop="id"></el-table-column>
                            <el-table-column label="用户名" prop="username"></el-table-column>
                            <el-table-column label="操作" width="200px">
                                <template #default="scope">
                                    <el-button size="mini" type="success" @click="increaseRank(scope.row.id)">升级</el-button>
                                    <el-button size="mini" type="danger" @click="removeUser(scope.row.id)">删除</el-button>
                                </template>
                            </el-table-column>
                        </div>
                    </div>
                </el-card>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'ManagerView',
    data() {
        return {
            currentActive: 1,
            userList: []
        }
    },
    methods: {
        handleSelect(active) {
            if (active < 10) {
                this.currentActive = active
            }
        },
        logout() {
            this.$router.push({ path: '/login' })
        },
        async removeUser(id){
            console.log(id)
        },
        async increaseRank(id){
            console.log(id)
        }
    }
}
</script>

<style lang="less" scoped>
.main {
    background: url("../assets/bg.jpg") no-repeat center;
    background-size: 100%;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;

    .header {
        width: 80%;
        margin: 0 auto 100px;
        padding: 0 15px;

        .header-menu {
            .flex-grow {
                flex-grow: 1;
            }
        }
    }
}
</style>